<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="/luckydog/index">首页</a>
                        </li>
                        <li>
                            <a href="#">活动</a>
                        </li>
                        <li class="active"> 活动列表 </li>
                    </ul>
                </div>
                <!-- Page Body -->
                <div class="page-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="widget">
                                <div class="widget-header ">
                                    <span class="widget-caption">活动列表</span>
                                    <div class="widget-buttons">
                                        <a href="#" data-toggle="maximize">
                                            <i class="fa fa-expand"></i>
                                        </a>
                                        <a href="#" data-toggle="collapse">
                                            <i class="fa fa-minus"></i>
                                        </a>
                                    </div>
                                </div>
                                <div class="widget-body">
                                 <div class="table-toolbar">
                                        <a  href="javascript:void(0);"  class=" btn btn-default edit_exam">
                                            创建活动
                                        </a>
                                    </div>
                                    <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                                        <thead>
                                            <tr>
                                                <th>活动id</th>
                                                <th>活动题目</th>
                                                <th>创建时间</th>
                                                <th>状态</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <?php if(!empty($examinationList)):?>
                                                <?php foreach($examinationList as $key=> $row):?>
                                                    <tr class="gradeX ">
                                                        <td class="center" style="text-align:center;width:90px;"><?php echo $row['paperID'];?></td>
                                                        <td class="center"><?php echo $row['paperTitle']?></td>
                                                        <td class="center"><?php echo  date("Y-m-d H:i:s",strtotime($row['createTime']))?></td>
                                                        <td class="center">
                                                                        <?php if($row['onlinestatus'] == 1){?>
                                                                            上架
                                                                        <?php }elseif($row['onlinestatus'] == 0){?>
                                                                            下架
                                                                        <?php }?>
                                                                    </td>
                                                                    <td class="center "  data_id = "<?php echo $row['paperID'];?>">
                                                                        <a style="color:blue;" href="javascript:;" class="edit_exam">修改</a>&nbsp;|
                                                                        <a  style="color:blue;" href="javascript:;" class="J_onlinestatus" type="onlinestatus" onlinestatus="<?php echo $row['onlinestatus'];?>" >
                                                                            <?php if($row['onlinestatus'] == 1){?>
                                                                                下架
                                                                            <?php }elseif($row['onlinestatus'] == 0){?>
                                                                                上架
                                                                            <?php }?>
                                                                        </a>|
                                                                        <a style="color:blue;" href="javascript:;" class="J_del">删除</a>
                                                                    </td>
                                                    </tr>
                                                <?php endforeach;?>
                                            <?php endif;?>
                                        </tr>
                                        <tr><td colspan="9"><div class="page_links"><?= $page_links?></div></td></tr>
                                        </tbody>

                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
<script src="<?php echo STATICURL; ?>js/jquery-2.0.3.min.js"></script>
<script src="<?php echo STATICURL; ?>layer/layer.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
     $('.edit_exam').on('click', function(){
        //iframe窗
        var id = $(this).parent().attr("data_id");
        var title = "修改";
        if(id == undefined){
            id = "";
            title = "添加";
        }
        layer.open({
            type: 2,
            title: title,
            shade: [0.5, '#000'],
            shadeClose: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['550px', '180px'],
            content: '/luckydog/examination/textures?id='+id
        });
    });
    $(document).ready(function() {
        $(".J_del").click(function() {
            var id = $(this).parent().attr("data_id");
            if (confirm("您确定要删除吗？")) {
                $.post("/luckydog/examination/editStatus", {"id":id,"type":"isDel"}, function(res) {
                    if (res) {
                        window.location.reload();
                    }else{
                        alert("删除失败");
                    }
                });
            }
        });

        $(".J_onlinestatus").click("click",function(){
            var id = $(this).parent().attr("data_id");
            var onlinestatus = $(this).attr("onlinestatus");
            var des = "确定上架吗？";
            if(onlinestatus == 1){
                onlinestatus = 0;
                des = "确定要下架吗？";
            }else{
                onlinestatus = 1;
            }
            if(confirm(des)){
                $.post("/luckydog/examination/editStatus",{"id":id,"onlinestatus":onlinestatus,"type":"onlinestatus"},function(res){
                    if(res){
                         window.location.reload();
                    }else{
                        alert("添加失败");
                    }
                });
            }
        });
        $(".J_Setstatus").click(function() {
            var id = $(this).parent().attr("data_id");
            var status = $(this).attr("status");
            if(status == 1){
                status = -1;
            }else{
                status = 1;
            }
            $.post("/luckydog/account/setStatus", {"id":id,"status":status}, function(res) {
                if (res) {
                    window.location.reload();
                }else{
                    alert("失败");
                }
            });
        });
    });


</script>


